package com.sfx.controller;

import com.sfx.model.ScopeUser;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * 公共的Bean
 */
@Component
public class ScopeUserBeans {
    //Bean作用域设置
    //@Scope("prototype")
    //多例作用域
    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    @Bean
    private ScopeUser doScopeUser(){
        ScopeUser scopeUser = new ScopeUser();
        scopeUser.setName("喜洋洋!!!");
        scopeUser.setId(8);
        scopeUser.setAge(19);
        return scopeUser;
    }
}
